<template>
  <page-meta :root-font-size="fontsize" style="display: block">
    <div class="myIntegral">
      <xlNavBar :isShare="isShare" title="我的积分" :isMark="false" bgc="transparent"></xlNavBar>
      <image class="my-integral-top" src="/pages3/static/my-integral-top.png" mode="scaleToFill" />
      <div class="my-integral-content">
        <div class="c-info">
          <div class="title">您当前剩余积分</div>
          <div class="bottom">
            <div class="left_num">{{ getUserInfo.integral || 0 }}</div>
            <div class="right_btn">
              <div class="btn btn1" v-if="$isIos() != 'IOS'" @click="tocz">去充值</div>
              <div class="btn btn2" @click="$togo('/pages3/integralDetail')">积分明细</div>
            </div>
          </div>
        </div>
        <div class="c-wrap">
          <div class="title">获取积分</div>
          <div class="item" v-if="showMfsjf == 1 || getUserInfo.integral <= 3" @click="showJfjlPopup = true">
            <image src="/pages3/static/2.png" class="left" mode="scaleToFill" />
            <div class="center">
              <div class="hb t1">邀请餐友赚积分</div>
              <div class="d2">每成功邀请一名餐友，可获得2积分 可免费拨打2个电话</div>
            </div>
            <div class="right">
              <text class="text">去邀请</text>
              <text class="iconfont cyjiantouyou"></text>
            </div>
          </div>
          <div class="item" v-if="$isIos() != 'IOS'">
            <image src="/pages3/static/1.png" class="left" mode="scaleToFill" />
            <div class="center" @click="tocz">
              <div class="t1">充值积分</div>
              <div class="d2">新用户首充5折，充值越多越优惠</div>
            </div>
            <div class="right" @click="tocz">
              <text class="text">去充值</text>
              <text class="iconfont cyjiantouyou"></text>
            </div>
          </div>
        </div>

        <div class="c-image">
          <div class="title">积分用途</div>
          <div class="list">
            <image src="/pages3/static/3.png" class="item" mode="scaleToFill" />
            <image src="/pages3/static/5.png" class="item" mode="scaleToFill" />
            <image src="/pages3/static/4.png" class="item" mode="scaleToFill" />
          </div>
        </div>
        <div class="c-bottom">
          <text class="t1">有疑问？</text>
          <text class="t2" @click="lxkf">联系餐饮信息网客服~</text>
        </div>
      </div>
      <jfjlPopup :show="showJfjlPopup" @close="showJfjlPopup = false"></jfjlPopup>
      <cyxxwkfPopup @close="close" title="餐饮信息网客服" cancelText="复制微信号" submitText="拨打电话" :show="showIosPopup"></cyxxwkfPopup>
    </div>
  </page-meta>
</template>

<script>
import jfjlPopup from "@/pages3/compontents/jfjlPopup.vue";
import config from "@/config.js";
import cyxxwkfPopup from "@/pages3/compontents/cyxxwkfPopup.vue";
import { mapGetters } from "vuex";
export default {
  components: { cyxxwkfPopup, jfjlPopup },
  name: "myIntegral",
  data() {
    return { isShare: 0, fontsize: "", showIosPopup: false, showJfjlPopup: false, integral: 0 };
  },
  onShow(options) {
    if (options.integral) {
      this.integral = options.integral || 0;
    } else {
      // this.getUserInfo();
    }
    let designWidth = 37.5; //因设计图的宽度
    let that = this;
    //窗体改变大小触发事件
    uni.onWindowResize(res => {
      //100*屏幕宽度/设计稿宽度
      that.fontsize = Math.floor((1.5 * res.size.windowWidth) / designWidth) + "px";
    });

    //打开获取屏幕大小
    uni.getSystemInfo({
      success(res) {
        that.fontsize = Math.floor((1.5 * res.screenWidth) / designWidth) + "px";
      },
    });
  },
  onLoad(options) {
    if (options.params) {
      let params = JSON.parse(decodeURIComponent(options.params));
      if (params.shareUserId) {
        this.$setStoraged("shareUserId", params.shareUserId);
        this.isShare = 1;
      }
    }
  },
  methods: {
    // 去充值
    tocz() {
      console.log(this.$isIos());
      if (this.$isIos() == "IOS") {
        this.showIosPopup = true;
      } else {
        this.$jump("/pages3/integralRechargePage");
      }
    },
    lxkf() {
      this.showIosPopup = true;
    },
    close() {
      uni.setClipboardData(
        {
          data: config.kfwxh, //要被复制的内容
          success: () => {
            //复制成功的回调函数
            uni.showToast({
              //提示
              title: `复制成功`,
              icon: "success",
            });
          },
        },
        true
      );

      this.showIosPopup = false;
    },
  },
  computed: {
    ...mapGetters("user", ["getUserInfo", "showMfsjf"]),
  },
};
</script>

<style lang="scss" scoped>
.myIntegral {
  position: relative;
  width: 100%;
  height: 100vh;
  background: #f7f7f7;
  box-sizing: border-box;
  .my-integral-top {
    position: absolute;
    z-index: 0;
    width: 100%;
    height: 358px;
  }
  .my-integral-content {
    position: absolute;
    z-index: 1;
    top: 98px;
    width: 100%;
    display: flex;
    flex-direction: column;
    .c-info {
      width: 100%;
      height: 120px;
      box-sizing: border-box;
      background-size: 100% 120px;
      background-position: center;
      background-repeat: no-repeat;
      background-image: url("https://chenxiao.obs.cn-north-1.myhuaweicloud.com/img/13_1679573695828580346.uRtSyybuTHd46383a9a5982ceeb2d4d2d9c2e0097857.png");
      padding: 20px 25px;
      font-size: 16px;
      font-weight: 600;
      color: #333333;
      display: flex;
      flex-direction: column;
      justify-content: center;
      .bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        .left_num {
          width: 150px;
          font-size: 32px;
          font-family: PingFang SC-Semibold, PingFang SC;
          font-weight: 600;
          color: #333333;
          margin-top: 20px;
          @include ells(1);
        }
        .right_btn {
          display: flex;
          margin-top: 20px;
          .btn {
            font-size: 12px;
            font-family: PingFang SC-Semibold, PingFang SC;
            font-weight: 600;
            color: #ffffff;
            text-align: center;
            line-height: 31px;
          }
          .btn1 {
            width: 74px;
            height: 31px;
            background: #ff8822;
            border-radius: 16px 16px 16px 16px;
          }
          .btn2 {
            width: 74px;
            height: 31px;
            border-radius: 16px 16px 16px 16px;
            opacity: 1;
            border: 1px solid #ff9f22;
            margin-left: 10px;
            font-size: 12px;
            font-family: PingFang SC-Semibold, PingFang SC;
            font-weight: 600;
            color: #ff8822;
          }
        }
      }
    }
    .c-wrap {
      width: calc(100% - 20px);
      box-sizing: border-box;
      margin: 0 10px;
      margin-top: 8px;
      padding: 0 10px;
      padding-bottom: 16px;
      background: #ffffff;
      border-radius: 10px;
      .title {
        height: 40px;
        line-height: 40px;
        font-weight: 600;
        color: #333333;
        border-bottom: 1px solid #e4e4e4;
      }
      .item {
        width: 100%;
        margin-top: 20px;
        display: flex;
        align-items: center;
        .left {
          width: 41px;
          height: 41px;
        }
        .center {
          flex: 1;
          margin: 0 6px;
          .t1 {
            font-size: 16px;
            font-weight: 600;
            color: #333333;
            @include ells(1);
          }
          .d2 {
            font-size: 13px;
            font-weight: 400;
            color: #999999;
            margin: 5px auto;
            @include ells(2);
          }
        }
        .right {
          font-size: 14px;
          font-family: PingFang SC-Medium, PingFang SC;
          color: #ff8822;
          .text {
            margin-right: 2px;
          }
          .iconfont {
            font-size: 12px;
            margin-bottom: 2px;
          }
        }
      }
    }
    .c-image {
      display: flex;
      flex-direction: column;
      width: calc(100% - 20px);
      box-sizing: border-box;
      margin: 0 10px;
      margin-top: 10px;
      padding: 0 10px;
      padding-bottom: 16px;
      background: #ffffff;
      border-radius: 10px;
      .title {
        height: 40px;
        line-height: 40px;
        font-weight: 600;
        color: #333333;
      }
      .list {
        display: flex;
        justify-content: space-between;
        .item {
          width: 100px;
          height: 100px;
        }
      }
    }
    .c-bottom {
      width: 100%;
      margin: 16px 0;
      display: flex;
      justify-content: center;
      font-size: 12px;
      color: #999999;
      .t2 {
        color: #ff8822;
      }
    }
  }

  .hb {
    position: relative;
    &::after {
      position: absolute;
      top: 2px;
      width: 60px;
      height: 18px;
      line-height: 18px;
      background: #f76a6a;
      font-size: 10px;
      color: #ffffff;
      border-radius: 9px;
      text-align: center;
      transform: scale(0.8);
      content: "火爆推荐";
    }
  }
}
</style>
